package com.yosaa.back.enums;
public enum MaleLungCapacityScore {
    EXCELLENT_100(100, 5040, 5140),
    EXCELLENT_95(95, 4920, 5020),
    EXCELLENT_90(90, 4800, 4900),
    GOOD_85(85, 4550, 4650),
    GOOD_80(80, 4300, 4400),
    PASS_78(78, 4180, 4280),
    PASS_76(76, 4060, 4160),
    PASS_74(74, 3940, 4040),
    PASS_72(72, 3820, 3920),
    PASS_70(70, 3700, 3800),
    PASS_68(68, 3580, 3680),
    PASS_66(66, 3460, 3560),
    PASS_64(64, 3340, 3440),
    PASS_62(62, 3220, 3320),
    PASS_60(60, 3100, 3200),
    FAIL_50(50, 2940, 3030),
    FAIL_40(40, 2780, 2860),
    FAIL_30(30, 2620, 2690),
    FAIL_20(20, 2460, 2520),
    FAIL_10(10, 2300, 2350);

    private final float score;
    private final int freshmanSophomore; // 大一大二标准
    private final int juniorSenior; // 大三大四标准

    MaleLungCapacityScore(float score, int freshmanSophomore, int juniorSenior) {
        this.score = score;
        this.freshmanSophomore = freshmanSophomore;
        this.juniorSenior = juniorSenior;
    }

    public float getScore() {
        return score;
    }

    public int getFreshmanSophomore() {
        return freshmanSophomore;
    }

    public int getJuniorSenior() {
        return juniorSenior;
    }

    /**
     * 根据肺活量值和年级计算分数
     *
     * @param lungCapacity 肺活量值
     * @param grade        年级
     * @return 分数
     */
    public static float calculateScore(float lungCapacity, String grade) {
        for (MaleLungCapacityScore standard : MaleLungCapacityScore.values()) {
            int threshold = grade.equals("大一") || grade.equals("大二")
                    ? standard.getFreshmanSophomore()
                    : standard.getJuniorSenior();
            if (lungCapacity >= threshold) {
                return standard.getScore();
            }
        }
        return 0; // 默认分数
    }
}